package com.example.star.mapper;

import com.example.star.entity.Song;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SongMapper {
    @Insert("INSERT INTO songs (songname, singername, musicData) VALUES (#{songname}, #{singername}, #{musicData})")
    void insertSong(Song song);

    @Select("SELECT COUNT(*) FROM songs WHERE songname = #{songname}")
    int countSongByName(String songname);

    // 查询所有歌曲
    @Select("SELECT * FROM songs")
    List<Song> getAllSongs();

    // 根据歌手名查询歌曲
    @Select("SELECT * FROM songs WHERE singername = #{singerName}")
    List<Song> getSongsBySingerName(@Param("singerName") String singerName);
}